This invention relates generally to operating systems, and more particularly to smart hibernation on operating systems with page translation.
A portion of the disclosure of this patent document contains material which is subject to copyright protection. The copyright owner has no objection to the facsimile reproduction by anyone of the patent document or the patent disclosure as it appears in the Patent and Trademark Office patent file or records, but otherwise reserves all copyright rights whatsoever. The following notice applies to the software and data as described below and in the drawings hereto: Copyright(copyright) 1998, Microsoft Corporation, All Rights Reserved.
In general, a computer must traverse through a lengthy initialization process known as booting to load and launch its operating system. This operating system is typically stored on some type of non-volatile secondary storage media (e.g., a magnetic hard disk). A computer""s processor, however, executes instructions from a volatile addressable memory (e.g., Dynamic Random Access Memory (DRAM)). This addressable memory generally must be initialized by a non-volatile memory residing in an EPROM (electronically programmable read-only memory). The initialization (i.e., boot-up) provides for the loading of a portion of the operating system from the hard disk into the volatile memory. Subsequently, using this portion of the operating system, the remaining loading and initialization of the operating system is completed.
Generally after each initialization, the computer comes up in a default state, regardless of a computer user""s prior activities. This forces the computer user to restart any applications and to reload files he/she is going to use. Additionally, prior to the computer user turning off the computer, in general, all files should be saved and all applications closed. Consequently, to return to work within different applications and on particular files, the computer user must turn on the computer, wait for its initialization to be completed and reload the applications and files. For example, if the computer user was editing a spreadsheet, once the computer completed its initialization process, the computer user must restart the spreadsheet application, reload the particular spreadsheet for editing and relocate the portion of the particular spreadsheet being edited.
Some computers have been designed to solve these problems through what is termed hibernation. Hibernation, generally, is defined as the turning off of a computer in such a way that the state of the computer is xe2x80x9cfrozenxe2x80x9d or xe2x80x9cpausedxe2x80x9d (i.e., taking a snapshot of the current state of the computer prior to shutting the computer down). The computer user need not save files nor close applications prior to shutting down the computer, and upon powering on the computer at some later time, the computer user is able to return to the exact state of the computer prior to hibernation of the computer (i.e., the snapshot of the prior state of the computer is restored).
For example, returning to the previously described spreadsheet example, the computer user could be editing the particular spreadsheet and decide at some point to stop and power down the computer. Instead of going through the formal shut down process (i.e., saving the particular spreadsheet, closing the spreadsheet application and powering down the computer), the computer user could choose to place the computer in a hibernation mode. Upon powering on the computer at some later point in time, the spreadsheet application would be open with that particular spreadsheet being edited at the same location as when the computer user decide to place the computer in hibernation mode.
Hibernation, in general, saves the state of a computer that is normally lost during a general power-down of the computer to a secondary non-volatile storage (e.g., the computer""s hard drive). The state being saved includes, but is not limited to, the state of volatile memory and the execution context of the processor along with the state of peripheral devices and their associated drivers. Through hibernation, without rebooting of the computer""s operating system and upon restoration of power to the computer, the saved state is restored allowing for the resumption of program execution at a point at which hibernation was invoked.
In general, a computer having an operating system with page translation has a volatile memory that is comprised of three different categories of pages: locked, idle and free. A locked page is a page that must always reside within a volatile memory (i.e., cannot be pushed out to a swap page or file on a secondary storage) due to the nature of the information contained therein. Examples include those portions of code that directly interact with certain hardware on the computer that requires the actual physical address of the page within volatile memory containing the code (e.g., a device driver for specific hardware within the computer). An idle page is defined as a page within a volatile memory that contains code from an application that has recently been executed. Code in idle pages is subject to being pushed out to the swap file to free up pages in volatile memory for other code applications that will be executed by the computer""s processor. Finally, a free page is a page within a volatile memory that currently is available and could be used later to hold code that may be executed by the computer""s processor.
Currently, two types of hibernation are in use in the computing industry. The first version of hibernation is illustrated in FIG. 1. FIG. 1 illustrates a secondary storage 102, having a special partition 104 and a volatile memory 106. In this type of hibernation, special partition 104 is a reserved portion of secondary storage 102, dedicated to the exclusive use of storing all locked, idle and free pages that make up volatile memory 106 during hibernation. Once the computer initiates hibernation, special code within the BIOS of the computer is executed to provide for a complete copy of all data in volatile memory 106 to special partition 104. This hibernation technique, however, requires knowledge of the hardware on the computer (i.e., the amount of volatile memory). Additionally, this technique unnecessarily saves the free pages in volatile memory.
Similarly, the second type of hibernation is illustrated in FIG. 2. FIG. 2 illustrates a secondary storage 202 having a contiguous portion 204 and a volatile memory 206 containing locked pages 208. This type of hibernation does not dedicate a specific portion of secondary storage 202, as does the first type. Rather, once the hibernation process commences, the operating system determines the size of volatile memory 206 and dynamically allocates the contiguous portion 204 on secondary storage 202 for hibernation. Subsequently, locked pages 208 are copied from volatile memory 206 to contiguous portion 204 of secondary storage 202, thereby completing the hibernation process. Because the code performing the hibernation is contained within locked pages 208 of volatile memory 206, this code is also written out to contiguous portion 204 during the hibernation process. Moreover, this type of hibernation is unable to use the regular file system code to write the locked memory out to disk because a disk access, in general, modifies the memory being written to disk. There is a need in the art for a computing system with a more efficient hibernation that saves only those pages having data with the computing system""s memory.
The above-mentioned shortcomings, disadvantages and problems are addressed by the present invention, which will be understood by reading and studying the following specification. A hibernation process creates a duplicate memory image of the pages that need to be saved (i.e. hibernated) within volatile memory. The pages to be hibernated include all pages whose state is locked and a portion, if not all, of the pages whose state is idle. If the duplicate memory image of the pages to be hibernated cannot, however, be created due to a lack of volatile memory, some or all of the idle pages are pushed out to a swap file on secondary storage to free more volatile memory for this duplication. The duplicate memory image of the pages to be hibernated, along with a corresponding page table identifying their location within volatile memory, are written out to a file on the secondary storage, completing the hibernation process and allowing the computer system to shut down in a hibernation mode. Subsequently, when the computer system is powered on, the volatile memory within the computer system is restored back to a state just prior to the invocation of hibernation. Restoration of the volatile memory is achieved by placing the pages of the duplicate memory image from the file on the secondary storage in to their original location in volatile memory based on the corresponding page table.